package leetcode.L35;

class Solution1 {
    public int searchInsert(int[] nums, int target) {
        if (nums.length == 0) { return -1; }
        int left = 0, right = nums.length - 1;
        int ans = nums.length;
        while (left <= right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] >= target) {
                ans=mid;
                right = mid - 1;
            }else {
                left = mid + 1;
            }
        }
        return ans;
    }
    public static void main(String[] args) {
        int[] nums = {1,3,5,6};
        int target = 7;
        System.out.println(new Solution1().searchInsert(nums, target));
    }
}
